package smodul

import "github.com/jinzhu/gorm"

type AdminUser struct {
	gorm.Model
	UserName string `gorm:"default:'username';type:varchar(100);unique_index;not null"`
	Password string `gorm:"default:'password';type:varchar(255);not null"`
	Permissions string `gorm:"default:3;type:smallint"`
}

func (a AdminUser)TableName()string{
	return "adminuser"
}

//Validation ..验证用户
func (a * AdminUser)Validation()bool{
	MysqlDB.Select("id").Where("user_name = ? and password = ?",a.UserName,a.Password).Limit(1).Find(a)
	if a.ID>0{
		return true
	}
	return  false
}